﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SvOtchet.DataModel.todb.OrganizationsTableAdapters;
using SvOtchet.DataModel.todb;
using SvOtchet.DataModel.sp.GetSubOrganizationWithEmptyReportTableAdapters;
using SvOtchet.DataModel.sp;

using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace SvOtchet.controls
{
    public partial class AdminReportV2 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            ///this.ASPxLabel1.Text = DateTime.Now.ToString() + DateTime.Now.Ticks.ToString();
            ///
            //Получаем список не отчитавшихся подразделений.
            GetSubOrganizationWithEmptyReportTableAdapter ad = new GetSubOrganizationWithEmptyReportTableAdapter();
            int orgs = Convert.ToInt32(this.orgs.Value);
            int month = Convert.ToInt32(this.monthnums.Value);
            int year = Convert.ToInt32(this.years.Value);
            GetSubOrganizationWithEmptyReport.GetSubOrganizationWithEmptyReportDataTable tbl = ad.GetData(month, year, orgs);
            if (tbl.Rows.Count > 0) // Есть не отчитавшиеся
            {
                this.MultiView1.ActiveViewIndex = 0;
            }
            else
            {
                //Все отчитались, показываем результат
                this.MultiView1.ActiveViewIndex = 1;
            }
        }

        protected void SaveButton_Click(object sender, EventArgs e)
        {

        }
        // экспорт
        protected void btnXlsExport_Click(object sender, EventArgs e)
        {
            this.gridExport.WriteXlsToResponse();
        }

        protected void grid_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
        {
            ASPxGridView2.DataBind();
        }
    }
}